package org.example.dept.controller;
import org.example.entity.Base.Result;
import org.example.dept.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Validated
@RestController
@RequestMapping("/dept")
public class DeptController {
    private final DeptService deptService;

    public DeptController(DeptService deptService) {
        this.deptService = deptService;
    }

    @GetMapping("/list")
    public Result list(){
        return Result.success(deptService.list());
    }

    @GetMapping("/listbypage")
    public Result listbypage(@RequestParam(name="PageNumber", defaultValue = "1")int PageNumber, @RequestParam(name="PageSize", defaultValue = "5")int PageSize){
        return Result.success(deptService.listbypage(PageNumber, PageSize));
    }
    @GetMapping("/deptl")
    List deptl(){
        return deptService.deptl();
    }
    @GetMapping("/getcollegelist")
    public Result getcollegelist(){
        return Result.success(deptService.getcollegelist());
    }

    @GetMapping("/getMajor")
    public Result getMajor(Integer parent_id){
        System.out.println(parent_id);
        return Result.success(deptService.getMajor(parent_id));
    }
}
